<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="count++">{{count}}</button>
        <button @click="changeCount">{{count}}</button>
        <!-- <div>{{ num }} --- {{ str }} --- {{ b }}</div>
        <button @click="num++">{{ num }}</button> -->
        <button @click="data[0].age++">{{data[0].age}}</button>
    </div>


    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const { createApp, ref, reactive, toRefs } = Vue;
        createApp({
            setup() {

                const state = reactive({
                    count: ref(10), // 这里可以自动解包
                    data: [
                        { name: '张三', age: 20 },
                        { name: '李四', age: 19 },
                    ]
                })

                const changeCount = () => {
                    state.count++;
                }


                return {
                    ...toRefs(state), // state.count state.data
                    changeCount
                }

            }
        }).mount("#app")
    </script>
</body>

</html>